package com.hbwxz.compareprice.impl;

import com.hbwxz.compareprice.HttpRequest;
import com.hbwxz.compareprice.PriceResult;
import com.hbwxz.utils.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 平台价策略接口
 *
 * @author shenzw
 * @date 2023/12/19
 */
@Slf4j
@Component(value = "platformPriceStrategyImpl")
public class PlatformPriceStrategyImpl {

    /**
     * 获取商品比价 - 默认
     *
     * @param productName 商品名称
     * @return PriceResult
     */
    public PriceResult getDefaultPriceResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取默认平台上【%s】价格", productName));
        HttpRequest.mockCostTimeOperation();
        PriceResult tBaoPriceResult = new PriceResult()
                .setPlatform("默认平台")
                .setPrice(9999);
        CommonUtils.printThreadLog(String.format("默认平台价格为%d", 9999));
        return tBaoPriceResult;
    }

    /**
     * 获取平台折扣 - 默认
     *
     * @param productName 商品名称
     * @return int
     */
    public int getDefaultDiscountResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取默认平台上【%s】优惠", productName));
        HttpRequest.mockCostTimeOperation();
        CommonUtils.printThreadLog(String.format("默认平台优惠为：%d", -1));
        return 1;
    }

    /**
     * 获取商品比价 - 淘宝
     *
     * @param productName 商品名称
     * @return PriceResult
     */
    public PriceResult getTbPriceResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取淘宝上【%s】价格", productName));
        HttpRequest.mockCostTimeOperation();
        PriceResult tBaoPriceResult = new PriceResult()
                .setPlatform("淘宝")
                .setPrice(5199);
        CommonUtils.printThreadLog(String.format("淘宝价格为 =【%d】", 5199));
        return tBaoPriceResult;
    }

    /**
     * 获取平台折扣 - 淘宝
     *
     * @param productName 商品名称
     * @return int
     */
    public int getTbDiscountResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取淘宝上【%s】优惠", productName));
        HttpRequest.mockCostTimeOperation();
        CommonUtils.printThreadLog(String.format("淘宝优惠为 =【%d】", -200));
        return 200;
    }

    /**
     * 获取商品比价 - 京东
     *
     * @param productName 商品名称
     * @return PriceResult
     */
    public PriceResult getJdPriceResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取京东上【%s】价格", productName));
        HttpRequest.mockCostTimeOperation();
        PriceResult tBaoPriceResult = new PriceResult()
                .setPlatform("京东")
                .setPrice(5299);
        CommonUtils.printThreadLog(String.format("京东价格为 =【%d】", 5299));
        return tBaoPriceResult;
    }

    /**
     * 获取平台折扣 - 京东
     *
     * @param productName 商品名称
     * @return int
     */
    public int getJdDiscountResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取京东上【%s】优惠", productName));
        HttpRequest.mockCostTimeOperation();
        CommonUtils.printThreadLog(String.format("京东优惠为 =【%d】", -150));
        return 150;
    }


    /**
     * 获取商品比价 - 拼多多
     *
     * @param productName 商品名称
     * @return PriceResult
     */
    public PriceResult getPddPriceResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取拼多多上【%s】价格", productName));
        HttpRequest.mockCostTimeOperation();
        PriceResult tBaoPriceResult = new PriceResult()
                .setPlatform("拼多多")
                .setPrice(5399);
        CommonUtils.printThreadLog(String.format("拼多多价格为 =【%d】", 5399));
        return tBaoPriceResult;
    }

    /**
     * 获取平台折扣 - 拼多多
     *
     * @param productName 商品名称
     * @return int
     */
    public int getPddDiscountResult(String productName) {
        CommonUtils.printThreadLog(String.format("获取拼多多上【%s】优惠", productName));
        HttpRequest.mockCostTimeOperation();
        CommonUtils.printThreadLog(String.format("拼多多优惠为 =【%d】", -5300));
        return 5300;
    }
}
